/*
** job.h for 42sh in /home/guina_b/
** 
** Made by benoit guina
** Login   <guina_b@epitech.net>
** 
** Started on  Fri Jan 01 00:00:00 2010 benoit guina
** Last update Fri Jan 01 00:00:00 2010 benoit guina
*/

#ifndef H_JOB
#define H_JOB

#include <sys/types.h>

/*
**  JOB_STATUS_FOREGROUND ->  JOB_STATUS_BACKGROUND : "job_bin &"
**  JOB_STATUS_FOREGROUND ->  JOB_STATUS_STOPPED    : Ctrl + Z
**  JOB_STATUS_BACKGROUND ->  JOB_STATUS_FOREGROUND : "fg"
**  JOB_STATUS_STOPPED    ->  JOB_STATUS_FOREGROUND : "fg"
**  JOB_STATUS_STOPPED    ->  JOB_STATUS_BACKGROUND : "bg"
*/

typedef enum e_job_status
{
  JOB_STATUS_FOREGROUND,
  JOB_STATUS_BACKGROUND,
  JOB_STATUS_STOPPED,
  JOB_STATUS_DONE
} e_job_status;

typedef struct s_job
{
  struct s_job *next;
  char *input;
  int num;
  pid_t pgid;
  pid_t pid;
  e_job_status status;
} t_job;

t_job *job_init();
void job_free(t_job *job);
int job_set_status(t_job *job, e_job_status status);
int job_sort(t_job *job0, t_job *job1);

#endif
